package A07Object;

import java.util.Objects;

public class Tset {
    public static void main(String[] args) throws CloneNotSupportedException {
        int[] arr = new int[]{0,1,2,3};
        //1.
        Object obj = new Object();
        String ob=obj.toString();
        System.out.println(ob);

        Student s=new Student();
        String s1=s.toString();
        System.out.println(s1);
        //默认打印地址值，和equals方法类似，如需打印具体值或者比较具体值，需要重写方法
        //2.
        Object obj2=new Object();
        Object obj3=new Object();
        System.out.println(obj2==obj3);

        Student s11=new Student();
        Student s111=new Student();
        System.out.println(s11.equals(s111));
        //3.克隆
        Student s22=new Student("libai",23,arr);
        Student s222=(Student)s22.clone();
        arr[2]=100;
        System.out.println(s22);
        System.out.println(s222);//浅克隆
        //克隆分为浅克隆和深克隆，浅克隆的引用数据类型会直接引用，特点是改变一个，另一个也会改变；深克隆会重新定义除串池外的引用数据类型；默认为浅克隆
        //深克隆是在clone重写方法里，提前获取引用变量，并进行修改修改
        //深克隆时也可以直接用第三方方法，如Gson0
        //equals isnull,nonnull
        boolean bl=Objects.equals(s22,s222);//先做非空判断，避免系统报错
        System.out.println(bl);
        Object obj4=new Object();

        boolean bl1=Objects.isNull(obj4);
        System.out.println(bl1);
        boolean bl2=Objects.nonNull(obj4);
        System.out.println(bl2);

    }
}
